<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
</head>

<body>

    <div id="app">
        <h1>{{name}} --- {{weatherInfo}}</h1>
        <br>
        <button @click='changeWeather'>切换天气</button>
    </div>

    <script>

        const vm = new Vue({
            el: '#app',
            data: {
                name: 'lijunjie123456',
                isHot: false,
                person:{
                    age:18,
                    name:'jack'
                }
            },
            mounted() {
                console.info("mounted.....")
            },
            created() {
                console.info("created.....")
            },
            computed: {
                weatherInfo() {
                    return this.isHot ? '炎热' : '凉爽'
                },
            },
            methods: {
                changeWeather() {
                    this.isHot = !this.isHot
                }
            },
            watch: {
                isHot: {
                    handler(newValue, oldValue) {
                        console.info(newValue, oldValue)
                    },
                },
                person: {
                    deep:true,
                    handler(newValue, oldValue) {
                        console.info("改变成:"+newValue, "原始值："+oldValue)
                    },
                },
            }   
        })

    </script>

</body>

</html>